<template>
  <view class="page">
    <view class="room-name">
      <text>{{ laboroom }}</text>
    </view>
    <view class="list">
      <view class="list-item"
            @click="navTo('/pages/modifyroomname/modifyroomname')">
        <text class="font">修改名称</text>
        <uni-icons class="right-icon" type="right" size="30rpx"/>
      </view>
      <view class="list-item"
            @click="navTo('/pages/roomallequip/roomallequip')">
        <text class="font">全部设备</text>
        <uni-icons class="right-icon" type="right" size="30rpx"/>
      </view>
      <view class="list-item">
        <text class="font">手动控制</text>
        <uni-icons class="right-icon" type="right" size="30rpx"/>
      </view>
      <view class="list-item">
        <text class="font">灯光聚合</text>
        <uni-icons class="right-icon" type="right" size="30rpx"/>
      </view>
      <view class="list-item">
        <text class="font">环境聚合</text>
        <uni-icons class="right-icon" type="right" size="30rpx"/>
      </view>
      <view class="list-item">
        <text class="font">实验仪器聚合</text>
        <uni-icons class="right-icon" type="right" size="30rpx"/>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  components: {},
  data() {
    return {
      laboroom: '获取失败',
    };
  },
  onLoad(data) {
    console.log(data);
    this.laboroom = data.roomName;
    // {
    //   "roomName": "卧室",
    //     "roomSerialnum": "19552006623064",
    //     "accountNum": "19552006623"
    // }
  },
  onUnload() {
    uni.removeStorageSync('modifyroom1');
    this.$forceUpdate()
    uni.removeStorageSync('modifyroom');
    this.$forceUpdate()
  },
  onShow() {
    // try {
    //   const value1 = uni.getStorageSync('modifyroom');
    //   if (value1 && value1.from === '/pages/roomsguanli/roomsguanli') {
    //     this.laboroom = value1.data.name_room;
    //     console.log(value1);
    //   }
    // } catch (e) {
    //   console.error(e);
    // }
    //
    // try {
    //   const value = uni.getStorageSync('modifyroom1');
    //   if (value && value.from === '/pages/index1/index1') {
    //     this.laboroom = value.data.name_room;
    //     console.log(this.value);
    //   }
    // } catch (e) {
    //   console.error(e);
    // }
  },
  methods: {
    navTo(url) {
      uni.navigateTo({
        url: url,
        success(res) {
          console.log('成功啦', res);
        },
        fail(err) {
          console.log('失败啦', err);
        }
      })
    },
    navBack() {
      uni.navigateBack({
        delta: 1
      })
    },
  },
};

</script>

<style scoped lang="scss">
.page {
  background-color: #e5e5e56e;
  height: 100vh;
  width: 100%;
}

.room-name {
  padding: 30rpx 30rpx 0 30rpx;
  color: #000000;
  font-size: 40rpx;
  font-weight: bold;
}

.list {
  background-color: #ffffff;
  border-radius: 50rpx;
  margin: 30rpx;
}

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 30rpx;
  transition: background-color 0.25s;

  &:active {
    background-color: #f0f0f0; // 高亮背景色
  }

  .right-icon {
    font-weight: bold;
  }

  .font {
    font-size: 30rpx;
    color: #000000;
  }
}
</style>